<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>项目查询管理</title>

<meta name="decorator" content="default" />
<style type="text/css">
#input {
	width: 200px;
}

#contact {
	width: 100px;
}
</style>
<script type="text/javascript">
	$(function() {
		$("#company_info").css('display', 'none');
		$("#show_info").click(function(e) {
			var isClose = $("#show_info").val();
			if (isClose == "关闭公司信息") {
				$("#show_info").val("打开公司信息");
			} else {
				$("#show_info").val("关闭公司信息");
			}
			$("#company_info").toggle();
		});

		var validate = $("#inputForms").validate({
			submitHandler : function(form) {
				if ($("#user").val() == -1) {
					alert("请选择员工");
					return false;
				}
				loading('正在提交，请稍等...');
				form.submit();
			}
		});
		
		var followMan=$("#followMan").val();
		var userId='${fns:getUser().id}';
		if(followMan!=userId){
			$("#updateProject").css("display","none");
			$("#addProjectContact").css("display","none");
			$("#projectShift").css("display","none");
		}
	});
	//二级联动查询用户
	function ajaxdept() {
		$("#user option:not(:first)").remove();
		$("#user").val("-1");
		var deptId = $("#dept").val();
		if (deptId == "" || deptId == null) {
			$("#s2id_user").find("a:first").find("span:first").html("请选择");
			return false;
		} else {
			$.ajax({
				type : "post",
				url : "${ctx}/crm/project/project/findUser",
				data : "deptId=" + deptId,
				success : function(data) {
					for ( var i = 0; i < data.length; i++) {
						$("#user").append(
								"<option value='"+data[i].id+"'>"
										+ data[i].name + "</option>");
					}
				}
			});
			$("#user option:first").prop("selected", 'selected');
			$("#s2id_user").find("a:first").find("span:first").html("请选择");
		}
	}
</script>

</head>
<body>
	<ul class="nav nav-tabs">
		<li>
			<a href="${ctx}/crm/project/project/">我的项目列表</a>
		</li>
		<li class="active">
			<a href="javascript:void(0)">项目信息</a>
		</li>
	</ul>
	<br />
	<p>
		<strong>
			<input class="btn btn-primary" style="margin-left:100px;margin-top:0px;" type="button" onclick="change()" value="打开公司信息" id="show_info" />
		</strong>
	</p>
	<div style="width: 1100px; margin: 0px auto; display: none;margin-top:-10px;" id="company_info">
		<form:form id="inputForm" modelAttribute="project" action="${ctx}/crm/project/project/save" method="post" class="form-horizontal">
			<form:hidden path="id" />
			<table class="table-form">
				<tr>
					<td class="tit">公司名：</td>
					<td><form:input path="findCustomer.name" htmlEscape="false" maxlength="100" class="input-xlarge " readonly="true" /></td>
					<td class="tit">行业：</td>
					<td style="width:200px;"><c:forEach items="${sysDict}" var="sysdict">
						<span>${sysdict.label}&nbsp;&nbsp;</span>
					</c:forEach>
					<c:if test="${empty sysDict}">
					<font>暂无行业</font>
					</c:if>
					</td>
				</tr>
				<tr>
					<td class="tit">地址：</td>
					<td style="word-break: keep-all; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;" title="${project.findCustomer.address}"><form:input path="findCustomer.address" htmlEscape="false" maxlength="64" style="width:500px;" readonly="true" class="input-xlarge " /></td>
					<td class="tit">网址：</td>
					<td style="width:200px;"><a href="${project.findCustomer.website}" target="_blank" >${project.findCustomer.website}</a></td>
				</tr>
				<tr>
					<td class="tit">简介：</td>
					<td colspan="3"><form:textarea path="findCustomer.content" htmlEscape="false" rows="4"  style="width:941px;height:110px;" class="input-xxlarge " readonly="true" /></td>
				</tr>
			</table>
		</form:form>
	</div>
	<div style="width: 1100px; margin: 0px auto; margin-top: 10px;">
		<form:form id="inputForm" modelAttribute="project" action="${ctx}/project/project/save" method="post" class="form-horizontal">
			<input type="hidden" id="followMan" value="${project.followMan}">
			<table class="table-form">
				<tr>
					<td class="tit">项目名：</td>
					<td><form:input path="name" htmlEscape="false" id="input" class="input-xlarge " readonly="true" /></td>
					<td class="tit">所属公司：</td>
					<td><form:input path="findCustomer.name" htmlEscape="false" id="input" class="input-xlarge " readonly="true" /></td>
					<td class="tit">开发人：</td>
					<td><form:input path="cname" htmlEscape="false" id="input" class="input-xlarge " readonly="true" /></td>
					
				</tr>
				<tr>
					<td class="tit">跟进人：</td>
					<td><form:input path="fname" htmlEscape="false" id="input" class="input-xlarge " readonly="true" /></td>
					<td class="tit">状态：</td>
					<td><form:input path="dname" htmlEscape="false" id="input" class="input-xlarge " readonly="true" /></td>
					<td class="tit">联系人：</td>
					<td><form:input path="findCustomerContact.name" htmlEscape="false" id="input" class="input-xlarge " readonly="true" /></td>
					
				</tr>
				<tr>
					<td class="tit">电话：</td>
					<td><form:input path="findCustomerContact.phone" htmlEscape="false" id="input" class="input-xlarge " readonly="true" /></td>
					<td class="tit">邮箱：</td>
					<td><form:input path="findCustomerContact.email" htmlEscape="false" id="input" class="input-xlarge " readonly="true" /></td>
					<td class="tit">QQ：</td>
					<td><form:input path="findCustomerContact.qq" htmlEscape="false" id="input" class="input-xlarge " readonly="true" /></td>
					
				</tr>
				<tr>
					<td class="tit">手机：</td>
					<td><form:input path="findCustomerContact.mobile" htmlEscape="false" id="input" class="input-xlarge " readonly="true" /></td>
					<td class="tit">微信：</td>
					<td><form:input path="findCustomerContact.wechat" htmlEscape="false" id="input" class="input-xlarge " readonly="true" /></td>
					<td class="tit">其它：</td>
					<td><form:input path="findCustomerContact.other" htmlEscape="false" id="input" class="input-xlarge " readonly="true" /></td>
					
				</tr>
				<tr>
					<td class="tit">开始时间：</td>
					<td><input name="beginTime" type="text" maxlength="20" id="input" class="input-medium Wdate " value="<fmt:formatDate value="${project.beginTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" readonly="readonly" /></td>
					<td class="tit">结束时间：</td>
					<td><input name="endTime" type="text" maxlength="20" id="input" class="input-medium Wdate " value="<fmt:formatDate value="${project.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" readonly="readonly" /></td>
				</tr>
				<tr>
					<td class="tit">内容：</td>
					<td colspan="5"><form:textarea path="content" readonly="true" htmlEscape="false" style="width:922px;height:107px;" rows="4"   class="input-xxlarge " /></td>
				</tr>
				<tr>
					<td class="tit">注意事项：</td>
					<td colspan="5"><form:input path="note" class="input-xlarge" style="width:921px;" readonly="true"/></td>
				</tr>
			</table>
		</form:form>
	</div>
	<sys:message content="${message}" />
	<div style="width: 1100px; margin: 0px auto; margin-top: 30px;">
		<table id="contentTable" style="table-layout: fixed;" class="table table-striped table-bordered table-condensed">
			<thead>
				<tr>
					<th>时间</th>
					<th>地点</th>
					<th>内容</th>
					<th>联系人</th>
					<th>跟进人</th>
					<th>状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${projectContact}" var="project">
					<tr>
						<td><fmt:formatDate value="${project.createDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
						<td>${project.address}</td>
						<td style="width: 100%; word-break: keep-all; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;" title="${project.content}">${project.content}</td>
						<td>${project.cname}</td>
						<td>${project.fname}</td>
						<td>${project.dname}</td>
						<td><a href="${ctx}/crm/project/projectcontact/delete?id=${project.id}">删除</a></td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
		<br/>
		<c:if test="${empty projectContact}">
			<p style="font-size: 22px; width: 200px; margin: 0px auto;">暂无联系记录</p>
		</c:if>
	</div>
	<br />
	<form:form id="inputForms" modelAttribute="project" action="${ctx}/crm/project/project/projectShift" method="post">
		<form:hidden path="id" id="projectId" />
		<table style="margin: auto;" >
			<tr>
		
				<td>
				 <shiro:hasPermission name="project:project:updateproject">
				 <c:if test="${project.followMan == fns:getUser().id}">
					<a id="updateProject" href="${ctx}/crm/business/businessProject/formChange?id=${project.id}&customerId=${project.customerId}">
						<input class="btn btn-primary" type="button" value="修改项目" />
					</a>
					</c:if>
				</shiro:hasPermission>
				</td>
				<td>
					<shiro:hasPermission name="project:projectcontact:addProjectContact">
					<a id="addProjectContact" href="${ctx}/crm/project/projectcontact/findinfo?id=${project.id}">
						<input class="btn btn-primary" type="button" value="添加联系记录" />
					</a>
					</shiro:hasPermission>
				</td>
				<td>部门:</td>
				<td>
					<select class="input-xlarge" id="dept" name="dept" style="width: 150px;" onchange="ajaxdept()">
						<option value="">请选择</option>
						<c:forEach items="${dept}" var="dept">
							<option value="${dept.id}">${dept.name}</option>
						</c:forEach>
					</select>
				</td>
				<td>员工:</td>
				<td>
					<form:select path="followMan" id="user" class="user" name="user" style="width:150px;">
						<option value="-1">请选择</option>
					</form:select>
				</td>
				<td>
				 <shiro:hasPermission name="project:project:projectShift">
					<input id="projectShift" class="btn btn-primary" type="submit" value="项目转移" />
					</shiro:hasPermission>
				</td>
				<td>
					<input id="btnCancel" class="btn btn-primary" type="button" value="返 回" onclick="history.go(-1)" />
				</td>
			</tr>
		</table>
	</form:form>
</body>
</html>